<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%> 
<html>
<body class="easyui-layout list_body"  >
	<form id="menuForm" name="menuForm">
		<div class="list_body_north" data-options="region:'north'"  border="false" >
			<!-- 查询表单 -->
				<div  class="datagrid-toolbar" border="false"  >
				<div>
					<span>清算开始日期:</span>
					<input type="text" id="stl_dt_start" value="${yestedayDate}" name="stl_dt_start" class="easyui-datebox" data-options="editable:false"/>
					<span>清算结束日期:</span>
					<input type="text" id="stl_dt_end" value="${yestedayDate}" name="stl_dt_end" class="easyui-datebox" data-options="editable:false"/>
					<span>会员编号:</span>
					<input type="text" id="custom_no" name="custom_no" class="easyui-textbox" />
					<span>会员名称:</span>
					<input type="text" id="custom_name" name="custom_name" class="easyui-textbox" />
					<br/>
					<span>会员手机号:</span>
					<input type="text" id="login_id" name="login_id" class="easyui-textbox" />
					<span>机构号:</span>
					<input type="text" id="ins_cd" name="ins_cd" class="easyui-textbox" />
					<span>交易渠道:</span>
					<input class="easyui-combobox" id="channel_no" name="channel_no" type="text"
						data-options="url:'../logStlmChntSum/getAllChannel.do', method:'get', valueField:'CHANNEL_NO', textField:'CHN_NM', editable:false"/>
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-search" onclick="doSearch()">查询</a>
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-reload" onclick="resetForm()">重置</a>
				</div>
			</div>
			<!-- 维护汇总数据 -->
			<div  class="datagrid-toolbar" border="false"  >
				交易总金额：<span id="all_amt"></span>
				会员手续费汇总：<span id="all_midfee"></span>
				会员结算手续费汇总：<span id="all_custom_stl_fee"></span>
				机构结算手续费汇总：<span id="all_ins_stl_fee"></span>
				成本手续费汇总：<span id="all_costfee"></span>
				毛利汇总：<span id="all_gross_profit"></span>
				净利汇总：<span id="all_net_profit"></span>
			</div>		
			<jiepos:buttonOperateTag menuCode="${menuCode }"></jiepos:buttonOperateTag>
		</div>
		<div data-options="region:'center'" border="false"  class="list_body_center">		
			<!-- 表格 -->
			<table id="menuTableId" fit="true"></table>
		</div>
	</form>
</body>
<script type="text/javascript">
	var grid;
	$(function() {
		//加载业务名称数据
		$('#channel_no').combobox({
	        url:"../logStlmChntSum/getAllChannel.do",
	        valueField:'CHANNEL_NO',
	        textField:'CHN_NM'
		});
		getTotalInfo();
		/*加载表格数据*/
		grid = $("#menuTableId").jpgrid({
			url : "getLogListJson.do",
			baseColumns: false,
			columns : [ {
				title : "清算日期",
				field : "STL_DT",
				align : 'center',
                width:100
			}, {
				title : "所属机构",
				field : "INS",
				align : 'center'
			}, {
				title : "会员编号",
				field : "CUSTOM_NO",
				align : 'center'
			}, {
				title : "会员名称",
				field : "CUSTOM_NAME",
				align : 'center'
			}, {
				title : "业务名称",
				field : "SERVICE_NAME",
				align : 'center'
			}, {
				title : "业务参数名称",
				field : "SERVICE_PARAM_NAME",
				align : 'center'
			}, {
				title : "交易金额",
				field : "AMT",
				align : 'center',
                width:100
			}, {
				title : "交易笔数",
				field : "CNT",
				align : 'center',
                width:100
			},  {
				title : "借记卡成本扣率",
				field : "SETTLE_DEBIT_RATE",
				align : 'center',
                width:100
			}, {
				title : "借记卡封顶手续费",
				field : "SETTLE_DEBIT_MAXFEE",
				align : 'center',
                width:100
			}, {
				title : "贷记卡成本扣率",
				field : "SETTLE_CREDIT_RATE",
				align : 'center',
                width:100
			}, {
				title : "会员手续费",
				field : "MIDFEE",
				align : 'center',
                width:100
			}, {
				title : "会员结算手续费",
				field : "CUSTOM_STL_FEE",
				align : 'center',
                width:100
			}, {
				title : "机构结算手续费",
				field : "INS_STL_FEE",
				align : 'center',
                width:100
			}, {
				title : "成本手续费",
				field : "COSTFEE",
				align : 'center',
                width:100
			}, {
				title : "毛利",
				field : "GROSS_PROFIT",
				align : 'center',
                width:100
			}, {
				title : "净利",
				field : "NET_PROFIT",
				align : 'center',
                width:100
			}, {
				title : "交易渠道",
				field : "CHANNEL_NO",
				align : 'center',
                width:200
			}],
			queryParams: getQueryParams()
		});
	});

	function doSearch() {
		grid.load(getQueryParams());
		getTotalInfo();
	}
	
	function getTotalInfo(){
		$.ajax({
			url : '../logStlOperatorSum/getLogStlOperatorInfoTotal.do',
			data : getQueryParams(),
			success : function(result) {
				$("#all_amt").html(result.ALL_AMT);
				$("#all_midfee").html(result.ALL_MIDFEE);
				$("#all_custom_stl_fee").html(result.ALL_CUSTOM_STL_FEE);
				$("#all_ins_stl_fee").html(result.ALL_INS_STL_FEE);
				$("#all_costfee").html(result.ALL_COSTFEE);
				$("#all_gross_profit").html(result.ALL_GROSS_PROFIT);
				$("#all_net_profit").html(result.ALL_NET_PROFIT);
			}
		});
	}

	function exportFile(url){
		var checkedItems = $('#menuTableId').datagrid('getChecked');
		if(!checkedItems){
			return false;
		};
		var ids = "";
		for(var i = 0 ; i < checkedItems.length; i++){
			ids = ids + "," + ((checkedItems[i]).STL_DT1+"_"+(checkedItems[i]).SERVICE_PARAM_UUID+"_"+(checkedItems[i]).CUSTOM_UUID);
		}
		ids = replaceFirst(ids);
		commonFileDownload(url+ids, "menuForm");
	}
	
	function getQueryParams(){
		var data = {
			stl_dt_start : $('#stl_dt_start').val(),
			stl_dt_end : $('#stl_dt_end').val(),
			custom_no : $('#custom_no').val(),
			custom_name : $('#custom_name').val(),
			login_id : $('#login_id').val(),
			ins_cd : $('#ins_cd').val(),
			channel_no : $('#channel_no').val()
		};
		return data;
	}
</script>
</html>
